package com.secure.it;

import com.secure.it.util.Constants;

import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.app.Activity;
import android.content.Intent;

public class MainActivity extends Activity implements OnClickListener {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main_activity);
		getActionBar().setDisplayHomeAsUpEnabled(true);

		final Button plainTextButton = (Button) findViewById(R.id.plainTextButton);
		final Button fileEncryptionButton = (Button) findViewById(R.id.fileEncryptButton);
		final Button fileDecryptnButton = (Button) findViewById(R.id.fileDecryptButton);

		plainTextButton.setOnClickListener(this);
		fileEncryptionButton.setOnClickListener(this);
		fileDecryptnButton.setOnClickListener(this);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case android.R.id.home:
			NavUtils.navigateUpFromSameTask(this);
			return true;
		}
		return super.onOptionsItemSelected(item);
	}

	@Override
	public void onClick(View v) {
		Intent intent = null;
		switch (v.getId()) {
		case R.id.plainTextButton:
			intent = new Intent(this, PlainTextActivity.class);
			break;

		case R.id.fileDecryptButton:
			intent = new Intent(this, FileEncryptDecryptActivity.class);
			intent.putExtra(Constants.ACTIVITY_FILE_MODE,
					Constants.FILE_DECRYPT);
			break;

		case R.id.fileEncryptButton:
			intent = new Intent(this, FileEncryptDecryptActivity.class);
			intent.putExtra(Constants.ACTIVITY_FILE_MODE,
					Constants.FILE_ENCRYPT);
			break;
		}

		if (intent != null)
			this.startActivity(intent);
	}
}
